package com.heyqing.topic.ReverseBits_0190;

import java.util.Scanner;

/**
 * ClassName:ReverseBits
 * Package:com.heyqing.topic.ReverseBits_0190
 * Description:
 *
 * @Date:2024/9/20
 * @Author:Heyqing
 */
public class ReverseBits {
    public int reverseBits(int n) {
        int res = 0;
        for (int i = 0; i < 32 && n != 0; ++i) {
            res |= (n & 1) << (31 - i);
            n >>>= 1;
        }
        return res;

    }

    public static void start() {
        Scanner sc = new Scanner(System.in);
        System.out.println("n:");
        int n = sc.nextInt();
        ReverseBits rb = new ReverseBits();
        int res = rb.reverseBits(n);
        System.out.println(res);
    }
}
